home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / amac44d.zip / SZR.BAT < prev    next >
DOS Batch File  |  1992-06-22  |  4KB  |  109 lines

  1. : SZR.BAT  Search/Replace ZIP Files                                   6/1/92
  2. :
  3. :1) SYNTAX:                          SZR.BAT %1 %2 %3
  4. :                                  ┌──────────┘  │  └───────────┐
  5. :             (Mode)              %1            %2             %3
  6. :                            Search Text     Replace Text   ZIP Name
  7. :         ----------------   -------------   ------------   --------
  8. :      a) Query                   [ ]           [ ]            [ ]
  9. :      b) Partial Query      Search Text        [ ]            [ ]
  10. :      c) Partial Query      Search Text     Replace Text      [ ]
  11. :      d) All command line   Search Text     Replace Text   ZIP Name
  12. :
  13. :         where:    %1  - Search Text
  14. :                   %2  - Replace Text
  15. :                   %3  - ZIP Name, no extension
  16. :                   [ ] - entered at query prompt
  17. :2) Requires FGREP.COM    INPUT.COM    DX.EXE   PKZIP.EXE  PKUNZIP.EXE
  18. :            SR.MAC
  19. :
  20. :*******************************************************************************
  21. :* Environment Variable        Action                                          *
  22. :* --------------------------- ----------------------------------------------- *
  23. :* set srmac=                  macro files are located in current directory    *
  24. :* set srmac=c:\mac\           macro files are located in c:\mac\ directory    *
  25. :* set sztemp=                 uses default c:\$zip$ for temporary directory   *
  26. :* set sztemp=e:\name          uses e:\name for temporary directory            *
  27. :*******************************************************************************
  28. :
  29. @echo OFF
  30. cls
  31. echo SZR.BAT,  June 1, 1992
  32. set S~~=%1
  33. set R~~=%2
  34. set file=%3
  35. break on
  36. if "%sztemp%" == "" set sztemp= c:\$zip$
  37. if     "%1" == ""    echo Search Text: [Enter terminates batch file]
  38. if not "%1" == ""    if not "%2" == "" goto 2b
  39. if not "%1" == ""    goto 1a
  40. INPUT.COM Search Text=/b
  41. if errorlevel=1 goto 6a
  42. set S~~=%ans%
  43. goto 2a
  44. :1a
  45. echo Search Text=%S~~%
  46. :2a
  47. set ans=
  48. if "%2" == "" echo Replace Text: [Enter removes search text]
  49. INPUT.COM Replace Text=/b
  50. :   if errorlevel=1 goto 6a, removed from SZR.BAT, June 1, 1992            *|
  51. set R~~=%ans%
  52. :2b
  53.  
  54. set ans=
  55. if not "%3" == "" goto 2c
  56. echo ZIP Name(s): [ZIP Name(s), no ZIP extn]  [Enter terminates batch file]
  57. INPUT.COM ZIP Name=/b
  58. if errorlevel=1 goto 6a
  59. set file=%ans%
  60. :2c
  61. if "%file%" == ""  goto 6a
  62. if not exist %file%.ZIP goto 6a
  63. :4a
  64. CLS
  65. echo SZR.BAT,  June 1, 1992
  66. echo Search Text   = %S~~%
  67. echo Replace Text  = %R~~%
  68. echo ZIP Name      = %file%.ZIP
  69.  
  70. if not exist %sztemp%\nul md %sztemp%
  71. PKUNZIP.EXE -o %file% %sztemp%
  72. echo.
  73. DX.EXE %sztemp% //v-/fattr:!a-/he:1/st:1/out:nul
  74. DX.EXE %sztemp%\*.exe *.com *.zip *.mac *.arc//v-/del/he:1/st:1/out:nul
  75. echo.
  76. FGREP.COM -fl %S~~% %sztemp%\*.* >c:\$.ql
  77. set >c:\$
  78. copy c:\$.ql c:\!
  79. Q.EXE C:\! /E%srmac%SR.MAC /L%srmac%SR.MAC
  80. echo.
  81. echo.
  82. DX.EXE %sztemp%\*.* //at:!a/he:1/st:1/sing
  83. echo.
  84. echo Answer: [G]o non-stop Adds above files to %3.ZIP, or [Y]es, [N]o,  ^C
  85. DX.EXE %sztemp%\;.bak //ex-/at:!a/run:'pkzip -f %file% %sztemp%\$n'/he:1/st:1
  86. echo Deleting temporary files and removing temporary directory %sztemp% . . .
  87. echo y | erase %sztemp%\*.* >nul
  88. rd %sztemp%
  89. if exist %sztemp%\nul echo Directory %sztemp% still exists . . .
  90. erase c:\!
  91. erase c:\$.*
  92. goto 7a
  93. :6a
  94. echo.
  95. if     "%S~~%"  == ""   echo Must specify Search Text . . . .
  96. if     "%R~~%"  == ""   echo Must specify Replace Text . . . .
  97. if not exist %file%.zip echo Can't Find ZIP_File %file%.zip . . . .
  98. if     "%file%" == ""   echo Must Specify ZIP_File . . . .
  99. echo Search/Replace──INCOMPLETE──
  100. goto 8a
  101. :7a
  102. echo.
  103. echo Search/Replace──Complete──
  104. PKUNZIP.EXE -vd %file%
  105. :8a
  106. echo.
  107. break off
  108. echo.
  109.